Repository navigation
Conversation
SysCapture.suspend() put the original stream back and resume() unconditionally installed the capture file again. Code that had replaced sys.stdout or sys.stderr in the meantime (for example with a StringIO) lost its stream the first time capture was suspended and resumed, which live logging with --log-cli-level does on every log record. Remember a stream that is not ours when suspending, and put it back on resume instead of the capture file. Fixes pytest-dev#10553 Co-authored-by: Claude Sonnet 5.5 <noreply@anthropic.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #10553
When capture is suspended and resumed (live logging with
--log-cli-leveldoes this for every record),SysCapture.resume()always reinstalled its own capture file. If the code under test had replacedsys.stdout/sys.stderrmeanwhile (e.g. with aStringIO), that replacement was silently dropped and later output went to the capture buffer instead.suspend()now remembers a stream that is not ours andresume()puts it back.Tested: new test in
testing/logging/test_reporting.pyfails before and passes after;testing/test_capture.pyandtesting/logging/test_reporting.pypass; ruff format/check clean.changelog/10553.bugfix.rstand added myself toAUTHORS.Co-authored-bycommit trailers (Claude Sonnet 5.5; I will review and understand the change before submitting).